/**
 * Created with IntelliJ IDEA
 * Description
 * User:华为
 * Date:2024/11/12
 * Time:10:13
 */
public class Text11_12 {
    public static void main(String[] args) {
        String str = "Hello";
        System.out.println(str.toLowerCase());
    }
    public static void main3(String[] args) {
        String s1="abc"+"def";//1
        String s2=new String(s1);//2
        if(s1.equals(s2))//3
            System.out.println(".equals succeeded");//4
        if(s1==s2)//5
            System.out.println("==succeeded");//6
    }

    public static void main2(String[] args) {
        //str1和str2都是指向一个对象，Hello在字符常量池里，但和str3不是同一个对象，newString重新开辟了一个空间

        String str1 = "Hello";
        String str2 = "Hello";
        String str3 = new String("Hello");

        System.out.println(System.identityHashCode(str1));
        System.out.println(System.identityHashCode(str2));
        System.out.println(System.identityHashCode(str3));

    }
    public static void main1(String[] args) {
        String str1 = "Hello";
        String str2 = "Hello";
        String str3 = new String("Hello");

        System.out.println(str1.equals(str2)); // true，内容相同
        System.out.println(str1.equals(str3)); // true，内容相同，尽管str3是通过new创建的不同对象
    }
}

